<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>忘记密码 - StudyRaid</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --bg-primary: #0d1117;
            --bg-secondary: #161b22;
            --bg-tertiary: #21262d;
            --text-primary: #f0f6fc;
            --text-secondary: #c9d1d9;
            --text-tertiary: #8b949e;
            --border-color: #30363d;
            --accent-color: #58a6ff;
            --success-color: #3fb950;
            --warning-color: #d29922;
            --danger-color: #f85149;
            --border-radius: 6px;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }

        body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 导航栏样式 */
        header {
            background-color: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
        }

        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
            text-decoration: none;
            display: flex;
            align-items: center;
        }

        .logo i {
            margin-right: 10px;
            color: var(--accent-color);
        }

        .nav-links {
            display: flex;
            gap: 24px;
        }

        .nav-links a {
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s;
        }

        .nav-links a:hover,
        .nav-links a.active {
            color: var(--text-primary);
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .search-box {
            position: relative;
        }

        .search-box input {
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 8px 12px;
            padding-left: 32px;
            color: var(--text-primary);
            width: 240px;
            font-size: 14px;
        }

        .search-box i {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--accent-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            cursor: pointer;
        }

        /* 忘记密码页面主要内容 */
        .forgot-container {
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            padding: 40px 0;
        }

        .forgot-card {
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 32px;
            width: 100%;
            max-width: 400px;
            box-shadow: var(--shadow);
        }

        .forgot-header {
            text-align: center;
            margin-bottom: 32px;
        }

        .forgot-logo {
            font-size: 32px;
            margin-bottom: 16px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .forgot-logo i {
            margin-right: 12px;
            color: var(--accent-color);
        }

        .forgot-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .forgot-subtitle {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .form-input {
            width: 100%;
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 12px 16px;
            color: var(--text-primary);
            font-size: 14px;
            transition: border-color 0.2s;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        .form-input.error {
            border-color: var(--danger-color);
        }

        .error-message {
            color: var(--danger-color);
            font-size: 12px;
            margin-top: 6px;
            display: none;
        }

        .success-message {
            color: var(--success-color);
            font-size: 14px;
            margin-top: 16px;
            text-align: center;
            display: none;
        }

        .btn {
            padding: 12px 16px;
            border-radius: var(--border-radius);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
            text-align: center;
            text-decoration: none;
            display: block;
            width: 100%;
        }

        .btn-primary {
            background-color: var(--accent-color);
            color: white;
        }

        .btn-primary:hover {
            background-color: #4a93e0;
        }

        .btn-primary:disabled {
            background-color: var(--bg-tertiary);
            color: var(--text-tertiary);
            cursor: not-allowed;
        }

        .btn-secondary {
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-secondary:hover {
            background-color: var(--bg-secondary);
        }

        .login-link {
            text-align: center;
            margin-top: 24px;
            font-size: 14px;
            color: var(--text-tertiary);
        }

        .login-link a {
            color: var(--accent-color);
            text-decoration: none;
            margin-left: 4px;
        }

        .login-link a:hover {
            text-decoration: underline;
        }

        /* 页脚 */
        footer {
            border-top: 1px solid var(--border-color);
            padding: 24px 0;
            margin-top: 40px;
            text-align: center;
            color: var(--text-tertiary);
            font-size: 14px;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                gap: 16px;
            }

            .nav-links {
                order: 3;
                width: 100%;
                justify-content: center;
            }

            .search-box input {
                width: 200px;
            }

            .forgot-card {
                padding: 24px;
                margin: 0 16px;
            }
        }

        /* 步骤指示器 */
        .steps {
            display: flex;
            justify-content: space-between;
            margin-bottom: 32px;
            position: relative;
        }

        .steps::before {
            content: '';
            position: absolute;
            top: 15px;
            left: 0;
            right: 0;
            height: 2px;
            background-color: var(--border-color);
            z-index: 1;
        }

        .step {
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            z-index: 2;
        }

        .step-number {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--bg-tertiary);
            border: 2px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 8px;
            transition: all 0.3s;
        }

        .step.active .step-number {
            background-color: var(--accent-color);
            border-color: var(--accent-color);
            color: white;
        }

        .step.completed .step-number {
            background-color: var(--success-color);
            border-color: var(--success-color);
            color: white;
        }

        .step.completed .step-number::after {
            content: '✓';
        }

        .step-label {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        .step.active .step-label {
            color: var(--text-primary);
        }

        .step-content {
            display: none;
        }

        .step-content.active {
            display: block;
        }
    </style>
</head>

<body>
    <!-- 导航栏 -->
    <header>
        <div class="container">
            <nav class="navbar">
                <a href="index.html" class="logo">
                    <i class="fas fa-graduation-cap"></i>
                    StudyRaid
                </a>

                <div class="nav-links">
                    <a href="index.html">首页</a>
                    <a href="explore.html">发现</a>
                    <a href="learning-path.html">学习路径</a>
                    <a href="my-courses.html">我的课程</a>
                </div>

                <div class="user-menu">
                    <div class="search-box">
                        <i class="fas fa-search"></i>
                        <input type="text" placeholder="搜索课程..." id="searchInput">
                    </div>
                    <div class="user-avatar">JS</div>
                </div>
            </nav>
        </div>
    </header>

    <!-- 忘记密码表单 -->
    <main>
        <div class="forgot-container">
            <div class="forgot-card">
                <div class="forgot-header">
                    <div class="forgot-logo">
                        <i class="fas fa-graduation-cap"></i>
                        StudyRaid
                    </div>
                    <h1 class="forgot-title">重置密码</h1>
                    <p class="forgot-subtitle">按照步骤重置您的账户密码</p>
                </div>

                <!-- 步骤指示器 -->
                <div class="steps">
                    <div class="step active" data-step="1">
                        <div class="step-number">1</div>
                        <div class="step-label">验证邮箱</div>
                    </div>
                    <div class="step" data-step="2">
                        <div class="step-number">2</div>
                        <div class="step-label">验证码</div>
                    </div>
                    <div class="step" data-step="3">
                        <div class="step-number">3</div>
                        <div class="step-label">新密码</div>
                    </div>
                </div>

                <!-- 步骤1：验证邮箱 -->
                <div class="step-content active" id="step1">
                    <form id="emailForm">
                        <div class="form-group">
                            <label for="email" class="form-label">邮箱地址</label>
                            <input type="email" id="email" class="form-input" placeholder="请输入您的邮箱" required>
                            <div class="error-message" id="emailError">请输入有效的邮箱地址</div>
                        </div>

                        <button type="submit" class="btn btn-primary" id="sendCodeBtn">发送验证码</button>
                    </form>

                    <div class="login-link">
                        记起密码了？
                        <a href="login.html">返回登录</a>
                    </div>
                </div>

                <!-- 步骤2：输入验证码 -->
                <div class="step-content" id="step2">
                    <p class="forgot-subtitle" style="text-align: center; margin-bottom: 20px;">
                        验证码已发送至 <span id="userEmail" style="color: var(--accent-color);"></span>
                    </p>

                    <form id="codeForm">
                        <div class="form-group">
                            <label for="verificationCode" class="form-label">验证码</label>
                            <input type="text" id="verificationCode" class="form-input" placeholder="请输入6位验证码"
                                maxlength="6" required>
                            <div class="error-message" id="codeError">请输入有效的验证码</div>
                        </div>

                        <div class="form-group">
                            <div style="display: flex; gap: 10px;">
                                <button type="submit" class="btn btn-primary" id="verifyCodeBtn">验证</button>
                                <button type="button" class="btn btn-secondary" id="resendCodeBtn"
                                    disabled>重新发送(60)</button>
                            </div>
                        </div>
                    </form>

                    <div class="login-link">
                        没有收到验证码？
                        <a href="#" id="changeEmailLink">更换邮箱</a>
                    </div>
                </div>

                <!-- 步骤3：设置新密码 -->
                <div class="step-content" id="step3">
                    <form id="passwordForm">
                        <div class="form-group">
                            <label for="newPassword" class="form-label">新密码</label>
                            <input type="password" id="newPassword" class="form-input" placeholder="请输入新密码" required>
                            <div class="error-message" id="newPasswordError">密码必须至少8个字符，包含字母和数字</div>
                        </div>

                        <div class="form-group">
                            <label for="confirmNewPassword" class="form-label">确认新密码</label>
                            <input type="password" id="confirmNewPassword" class="form-input" placeholder="请再次输入新密码"
                                required>
                            <div class="error-message" id="confirmNewPasswordError">两次输入的密码不一致</div>
                        </div>

                        <button type="submit" class="btn btn-primary" id="resetPasswordBtn">重置密码</button>
                    </form>

                    <div class="success-message" id="successMessage">
                        <i class="fas fa-check-circle"></i> 密码重置成功！即将跳转到登录页面...
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer>
        <div class="container">
            <p>© 2023 StudyRaid. 保留所有权利。</p>
            <p>采用 GitHub 深色风格设计</p>
        </div>
    </footer>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            // DOM元素
            const steps = document.querySelectorAll('.step');
            const stepContents = document.querySelectorAll('.step-content');
            const emailForm = document.getElementById('emailForm');
            const codeForm = document.getElementById('codeForm');
            const passwordForm = document.getElementById('passwordForm');
            const emailInput = document.getElementById('email');
            const userEmailSpan = document.getElementById('userEmail');
            const verificationCodeInput = document.getElementById('verificationCode');
            const newPasswordInput = document.getElementById('newPassword');
            const confirmNewPasswordInput = document.getElementById('confirmNewPassword');
            const sendCodeBtn = document.getElementById('sendCodeBtn');
            const verifyCodeBtn = document.getElementById('verifyCodeBtn');
            const resetPasswordBtn = document.getElementById('resetPasswordBtn');
            const resendCodeBtn = document.getElementById('resendCodeBtn');
            const changeEmailLink = document.getElementById('changeEmailLink');
            const successMessage = document.getElementById('successMessage');

            // 错误信息元素
            const emailError = document.getElementById('emailError');
            const codeError = document.getElementById('codeError');
            const newPasswordError = document.getElementById('newPasswordError');
            const confirmNewPasswordError = document.getElementById('confirmNewPasswordError');

            let currentStep = 1;
            let countdown = 60;
            let countdownInterval;

            // 邮箱验证函数
            function validateEmail(email) {
                const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                return re.test(email);
            }

            // 验证密码
            function validatePassword(password) {
                if (password.length < 8) {
                    return false;
                }

                // 检查是否包含字母和数字
                const hasLetter = /[a-zA-Z]/.test(password);
                const hasNumber = /[0-9]/.test(password);

                return hasLetter && hasNumber;
            }

            // 更新步骤
            function updateStep(stepNumber) {
                currentStep = stepNumber;

                // 更新步骤指示器
                steps.forEach(step => {
                    const stepNum = parseInt(step.dataset.step);
                    step.classList.remove('active', 'completed');

                    if (stepNum < stepNumber) {
                        step.classList.add('completed');
                    } else if (stepNum === stepNumber) {
                        step.classList.add('active');
                    }
                });

                // 更新步骤内容
                stepContents.forEach(content => {
                    content.classList.remove('active');
                    if (content.id === `step${stepNumber}`) {
                        content.classList.add('active');
                    }
                });
            }

            // 开始倒计时
            function startCountdown() {
                resendCodeBtn.disabled = true;
                countdown = 60;

                countdownInterval = setInterval(() => {
                    countdown--;
                    resendCodeBtn.textContent = `重新发送(${countdown})`;

                    if (countdown <= 0) {
                        clearInterval(countdownInterval);
                        resendCodeBtn.disabled = false;
                        resendCodeBtn.textContent = '重新发送';
                    }
                }, 1000);
            }

            // 步骤1：发送验证码
            emailForm.addEventListener('submit', function (e) {
                e.preventDefault();

                // 验证邮箱
                if (!emailInput.value) {
                    emailInput.classList.add('error');
                    emailError.style.display = 'block';
                    return;
                } else if (!validateEmail(emailInput.value)) {
                    emailInput.classList.add('error');
                    emailError.textContent = '请输入有效的邮箱地址';
                    emailError.style.display = 'block';
                    return;
                } else {
                    emailInput.classList.remove('error');
                    emailError.style.display = 'none';
                }

                // 模拟发送验证码
                sendCodeBtn.disabled = true;
                sendCodeBtn.textContent = '发送中...';

                setTimeout(() => {
                    // 更新用户邮箱显示
                    userEmailSpan.textContent = emailInput.value;

                    // 更新步骤
                    updateStep(2);

                    // 开始倒计时
                    startCountdown();

                    // 重置按钮状态
                    sendCodeBtn.disabled = false;
                    sendCodeBtn.textContent = '发送验证码';

                    alert('验证码已发送到您的邮箱，请查收。');
                }, 1500);
            });

            // 步骤2：验证验证码
            codeForm.addEventListener('submit', function (e) {
                e.preventDefault();

                // 验证验证码
                if (!verificationCodeInput.value || verificationCodeInput.value.length !== 6) {
                    verificationCodeInput.classList.add('error');
                    codeError.style.display = 'block';
                    return;
                } else {
                    verificationCodeInput.classList.remove('error');
                    codeError.style.display = 'none';
                }

                // 模拟验证验证码
                verifyCodeBtn.disabled = true;
                verifyCodeBtn.textContent = '验证中...';

                setTimeout(() => {
                    // 更新步骤
                    updateStep(3);

                    // 重置按钮状态
                    verifyCodeBtn.disabled = false;
                    verifyCodeBtn.textContent = '验证';

                    // 清除倒计时
                    clearInterval(countdownInterval);
                    resendCodeBtn.disabled = false;
                    resendCodeBtn.textContent = '重新发送';
                }, 1000);
            });

            // 重新发送验证码
            resendCodeBtn.addEventListener('click', function () {
                // 模拟重新发送验证码
                resendCodeBtn.disabled = true;
                resendCodeBtn.textContent = '发送中...';

                setTimeout(() => {
                    // 开始倒计时
                    startCountdown();

                    alert('验证码已重新发送到您的邮箱，请查收。');
                }, 1000);
            });

            // 更换邮箱
            changeEmailLink.addEventListener('click', function (e) {
                e.preventDefault();
                updateStep(1);
            });

            // 步骤3：设置新密码
            passwordForm.addEventListener('submit', function (e) {
                e.preventDefault();

                let isValid = true;

                // 验证新密码
                if (!validatePassword(newPasswordInput.value)) {
                    newPasswordInput.classList.add('error');
                    newPasswordError.style.display = 'block';
                    isValid = false;
                } else {
                    newPasswordInput.classList.remove('error');
                    newPasswordError.style.display = 'none';
                }

                // 验证确认密码
                if (newPasswordInput.value !== confirmNewPasswordInput.value) {
                    confirmNewPasswordInput.classList.add('error');
                    confirmNewPasswordError.style.display = 'block';
                    isValid = false;
                } else {
                    confirmNewPasswordInput.classList.remove('error');
                    confirmNewPasswordError.style.display = 'none';
                }

                if (!isValid) return;

                // 模拟重置密码
                resetPasswordBtn.disabled = true;
                resetPasswordBtn.textContent = '重置中...';

                setTimeout(() => {
                    // 显示成功消息
                    successMessage.style.display = 'block';

                    setTimeout(() => {
                        // 跳转到登录页面
                        window.location.href = 'login.html';
                    }, 2000);
                }, 1500);
            });
        });
    </script>
</body>

</html>